package dao

import (
	"doctor_srv/global"
	"doctor_srv/model"
	"errors"
	"gorm.io/gorm"
)

func GetDoctorByAccount(account string) (*model.Doctor, error) {
	var doctor model.Doctor
	err := global.DB.Where("account  = ?", account).First(&doctor).Error
	if err != nil {
		if errors.Is(err, gorm.ErrRecordNotFound) {
			return nil, errors.New("用户不存在")
		}
		return nil, err
	}
	return &doctor, nil
}
